package org.asset;

import com.alibaba.fastjson.JSON;

import org.asset.Object.Person;

public class Main {
    public static void main(String[] args) {

        // object to json string
        Person person1 = new Person("Alice", 30);
        String jsonString1 = JSON.toJSONString(person1);
        System.out.println(jsonString1); // 输出: {"age":30,"name":"Alice"}

        // json string to object
        String jsonString2 = "{\"age\":18,\"name\":\"liheng\"}";
        Person person2 = JSON.parseObject(jsonString2, Person.class);
        System.out.println(person2.getName()); // 输出: liheng
        System.out.println(person2.getAge());  // 输出: 18

        // serialization and deserialization


    }
}

